#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

bool cmp(int a, int b);

int main(int argc, char const *argv[]){
    int buf_block[600];
    int L, N;
    while(scanf("%d %d", &L, &N) != EOF){
        for (int i = 0; i < N; i++)
            scanf("%d", &buf_block[i]);
        sort(buf_block, buf_block+N, cmp);
        int num_of_blocks = 0;
        int current_length = 0;
        bool enough = false;
        for (int i = 0; i < N; i++){
            current_length += buf_block[i];
            num_of_blocks++;
            if (current_length >= L){
                enough = true;
                break; 
            } 
        }
        if (enough == true)
            printf("%d\n", num_of_blocks);
        else
            printf("impossible\n");
    }
    return 0;
}

bool cmp(int a, int b){
    return a > b;
}
